$(document).ready(function()
{	  
    var selectedValue = "1252431";
    $('#cbo_city option').filter(function () {
        return ($(this).val() == selectedValue);
    }).attr('selected','selected');        

    $('#cbo_city').change(function(){
        var cityID = $('#cbo_city').val();
        if (cityID != ""){
            var post_url = "/thoi-tiet/" + cityID;
            $.ajax({
                type: "POST",
                url: post_url,
                success: function(data)
                {
                    var jsonData = jQuery.parseJSON( data );
                    if (data == 0) return;
                    $('#img_temperature').attr('src', jsonData.icon_url);
                    $('#temperature').html(jsonData.temp[0]);
                    $('#condition').html(jsonData.conditions);

                    var d = new Date(jsonData.date1[0]);
                    $('#img_temperature1').attr('src', jsonData.icon_url1);
                    $('#day1').html(d.getDate() + "/" + (d.getMonth()+1));
                    $('#low1').html(jsonData.low1[0]);
                    $('#high1').html(jsonData.high1[0]);
                    $('#condition1').html(jsonData.text1);

                    d = new Date(jsonData.date2[0]);
                    $('#img_temperature2').attr('src', jsonData.icon_url2);
                    $('#day2').html(d.getDate() + "/" + (d.getMonth()+1));
                    $('#low2').html(jsonData.low2[0]);
                    $('#high2').html(jsonData.high2[0]);
                    $('#condition2').html(jsonData.text2);

                    d = new Date(jsonData.date3[0]);
                    $('#img_temperature3').attr('src', jsonData.icon_url3);
                    $('#day3').html(d.getDate() + "/" + (d.getMonth()+1));
                    $('#low3').html(jsonData.low3[0]);
                    $('#high3').html(jsonData.high3[0]);
                    $('#condition3').html(jsonData.text3);
                } 
            }); 
        } 
    });	

    $('#cbo_city').val(selectedValue).change();    
    $("a#view-exrate").fancybox({
        helpers : { 
            title : { type : 'top' }
        },
        beforeLoad: function() {
            this.title = $(this.element).attr('caption');
        } 
    });

});   